using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Resources;
using System.Windows.Forms;
using Infragistics.Excel;
using Infragistics.UltraChart.Resources.Appearance;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win.UltraWinGrid;
using PluginFrame;

namespace PcrDataStructure
{
	[Serializable]
	public class PcrExperiment : IPcrExperiment
	{
		protected delegate AnalysisError AnalyzeDelegate(Dictionary<string, List<IPcrCell>> projectCells, IPcrExperiment pcrExperiment, IAbsoluteAnalysisParameterConfiguration analysisOption, IMeltingAnalysisParameterConfiguration meltingOption, bool isOnlyMeltingCurve);

		protected PcrSystemType mSystemType;

		protected Guid mGuid;

		protected string mRemark;

		protected int mIndexInTab;

		protected PcrModuleState mModuleState;

		protected bool mIsAvailable;

		protected string mName;

		protected string mTabDisplayName;

		protected string mResultFile;

		protected List<ISubModule> mSubModules = new List<ISubModule>();

		protected List<IPcrModule> mPcrModules = new List<IPcrModule>();

		protected List<IPcrExperimentProject> mProjects;

		protected IPcrProgram mPcrProgram;

		protected bool[] mIsChannelUsed;

		protected int mAvailableChannelAmount;

		protected TemperatureControlType mTemperatureControlType;

		protected double mTubeVolume;

		protected bool mIsUseHotLid;

		protected double mHotLidSettingTemperature;

		protected bool mIsDisplay;

		protected bool mIsWithExperimentController;

		protected Dictionary<string, UltraGridColumn> mColumnConfiguration;

		protected List<string> mColumnList;

		protected PcrExperimentStatus mStatus;

		protected bool mHasPassword;

		protected bool mIsPasswordMatch;

		protected string mPassword;

		protected IPrintOption mPrintOptions;

		protected IPcrStructure mPcrStructure;

		protected DateTime mStartTime;

		protected DateTime mStopTime;

		protected IRunningStatus mRunningStatus;

		protected List<int> mTabIndexs;

		protected List<IPcrCell> mPcrCellsInExperiment;

		protected bool mIsWithMeltingCurveResult;

		protected bool mIsWitAmplificationResult;

		protected int mAmplificationStartCycle;

		protected int mAmplificationStopCycle;

		protected int mMeltingStartCycle;

		protected int mMeltingStopCycle;

		protected IStaffConfiguration mOperator;

		protected IStaffConfiguration mAssessor;

		protected bool mIsDynamicAnalysis;

		protected List<double> mBlockTemperature;

		protected List<double> mHotLidTemperature;

		protected List<double> mTubeTemperature;

		protected string mDefaultLabelString;

		protected bool mIsLabelSortIncrease;

		protected int mLabelStartValue;

		protected int mLabelInterval;

		protected int mLabelBits;

		protected double mSplitterVerticalRate;

		protected double mSplitterHorizontalRate;

		protected CurveColorStyle mCurveColorStyle;

		protected CellDisplaySortStyle mCellDisplaySortStyle;

		protected CellDisplaySortStyle mMultiCellPlacementStyle;

		protected bool mIsHideParameterPanel;

		protected Dictionary<string, IPcrStandardCurve> mCurrentImportStandardCurve;

		protected LightScanStyle mLightSacnStyle;

		protected string mSoftwareVersion;

		protected List<string> mCellSourceFileNames;

		protected List<IProjectProperty> mProjectProjerties;

		protected int mTabIndex;

		[NonSerialized]
		protected ResourceManager mResourceManager;

		[NonSerialized]
		protected IApplication mApplication;

		[NonSerialized]
		protected IConfigurationService mConfigurationService;

		[NonSerialized]
		protected IRuleEditorService mRuleEditorService;

		[NonSerialized]
		protected IAnalysisService mAnalysisService;

		[NonSerialized]
		protected IMiscService mMiscService;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries[,]> mProjectThresholdCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries[,]> mMeltingThresholdCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries[,]> mMeltingMinTemperatureCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries[,]> mMeltingMaxTemperatureCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries> mHRMBeforeMeltingStartCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries> mHRMBeforeMeltingStopCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries> mHRMAfterMeltingStartCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, XYSeries> mHRMAfterMeltingStopCurves;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, Dictionary<string, List<IPcrCell>>[,]> mCellTypeLists;

		[NonSerialized]
		protected Dictionary<IPcrExperimentProject, IAnalysisResult[,]> mAnalysisResults;

		[NonSerialized]
		protected IPcrExperimentProject mDefaultProject;

		[NonSerialized]
		protected bool mRestartShowAmplificationCurve;

		[NonSerialized]
		protected bool mRestartShowMeltingCurve;

		[NonSerialized]
		protected UltraDataSource mCellGridDataSource;

		[NonSerialized]
		protected List<string>[] mDisplayedResultColumns;

		[NonSerialized]
		protected bool mIsChanged;

		[NonSerialized]
		protected bool mAllProjectsReAnalysis;

		[NonSerialized]
		protected bool mIsSkipDetectionSegment;

		[NonSerialized]
		protected bool mIsImportStandardCurve;

		[NonSerialized]
		protected bool mIsContinueHRM;

		[NonSerialized]
		protected double mHRMRamp;

		public double HRMRamp
		{
			get
			{
				return mHRMRamp;
			}
		}

		public string SoftwareVersion
		{
			get
			{
				return mSoftwareVersion;
			}
			set
			{
				mSoftwareVersion = value;
			}
		}

		public LightScanStyle LightScanStyle
		{
			get
			{
				return mLightSacnStyle;
			}
			set
			{
				mLightSacnStyle = value;
			}
		}

		public Guid Guid
		{
			get
			{
				return mGuid;
			}
		}

		public IStaffConfiguration Operator
		{
			get
			{
				return mOperator;
			}
			set
			{
				mOperator = value;
			}
		}

		public IStaffConfiguration Assessor
		{
			get
			{
				return mAssessor;
			}
			set
			{
				mAssessor = value;
			}
		}

		public int AmplificationStartCycle
		{
			get
			{
				return mAmplificationStartCycle;
			}
			set
			{
				mAmplificationStartCycle = value;
			}
		}

		public int AmplificationStopCycle
		{
			get
			{
				return mAmplificationStopCycle;
			}
			set
			{
				mAmplificationStopCycle = value;
			}
		}

		public int MeltingStartCycle
		{
			get
			{
				return mMeltingStartCycle;
			}
			set
			{
				mMeltingStartCycle = value;
			}
		}

		public int MeltingStopCycle
		{
			get
			{
				return mMeltingStopCycle;
			}
			set
			{
				mMeltingStopCycle = value;
			}
		}

		public List<string>[] DisplayedResultColumns
		{
			get
			{
				return mDisplayedResultColumns;
			}
			set
			{
				mDisplayedResultColumns = value;
			}
		}

		public PcrSystemType SystemType
		{
			get
			{
				return mSystemType;
			}
			set
			{
				mSystemType = value;
			}
		}

		public int IndexInTab
		{
			get
			{
				return mIndexInTab;
			}
			set
			{
				mIndexInTab = value;
			}
		}

		bool IPcrExperiment.HasPassword
		{
			get
			{
				return mHasPassword;
			}
			set
			{
				mHasPassword = value;
			}
		}

		bool IPcrExperiment.IsPasswordMatch
		{
			get
			{
				return mIsPasswordMatch;
			}
			set
			{
				mIsPasswordMatch = value;
			}
		}

		string IPcrExperiment.Password
		{
			get
			{
				return mPassword;
			}
			set
			{
				mPassword = value;
			}
		}

		PcrExperimentStatus IPcrExperiment.Status
		{
			get
			{
				return mStatus;
			}
			set
			{
				mStatus = value;
			}
		}

		Dictionary<string, UltraGridColumn> IPcrExperiment.ColumnConfiguration
		{
			get
			{
				return mColumnConfiguration;
			}
			set
			{
				mColumnConfiguration = value;
			}
		}

		public List<string> ColumnList
		{
			get
			{
				return mColumnList;
			}
			set
			{
				mColumnList = value;
			}
		}

		List<IPcrModule> IPcrExperiment.PcrModules
		{
			get
			{
				return mPcrModules;
			}
			set
			{
				mPcrModules = value;
			}
		}

		public string Remark
		{
			get
			{
				return mRemark;
			}
			set
			{
				mRemark = value;
			}
		}

		public DateTime StartTime
		{
			get
			{
				return mStartTime;
			}
			set
			{
				mStartTime = value;
			}
		}

		public DateTime StopTime
		{
			get
			{
				return mStopTime;
			}
			set
			{
				mStopTime = value;
			}
		}

		public IPcrProgram PcrProgram
		{
			get
			{
				return mPcrProgram;
			}
			set
			{
				mPcrProgram = value;
			}
		}

		public List<IPcrExperimentProject> Projects
		{
			get
			{
				return mProjects;
			}
		}

		double IPcrExperiment.ReactionVolume
		{
			get
			{
				if (mProjects != null && mProjects.Count > 0)
				{
					return mProjects[0].ReactionVolume;
				}
				return 0.0;
			}
		}

		public string Name
		{
			get
			{
				return mName;
			}
			set
			{
				mName = value;
			}
		}

		public string TabDisplayName
		{
			get
			{
				return mTabDisplayName;
			}
			set
			{
				mTabDisplayName = value;
			}
		}

		public string ResultFile
		{
			get
			{
				return mResultFile;
			}
			set
			{
				mResultFile = value;
			}
		}

		public List<IProjectProperty> ProjectProjerties
		{
			get
			{
				return mProjectProjerties;
			}
			set
			{
				mProjectProjerties = value;
			}
		}

		public int AvailableChannelAmount
		{
			get
			{
				return mAvailableChannelAmount;
			}
			set
			{
				mAvailableChannelAmount = value;
			}
		}

		public bool[] IsChannelUsed
		{
			get
			{
				return mIsChannelUsed;
			}
		}

		public List<ISubModule> SubModules
		{
			get
			{
				return mSubModules;
			}
			set
			{
				mSubModules = value;
			}
		}

		IPrintOption IPcrExperiment.PrintOptions
		{
			get
			{
				return mPrintOptions;
			}
			set
			{
				mPrintOptions = value;
			}
		}

		IPcrStructure IPcrExperiment.PcrStructure
		{
			get
			{
				return mPcrStructure;
			}
			set
			{
				mPcrStructure = value;
			}
		}

		public PcrModuleState ModuleState
		{
			get
			{
				return mModuleState;
			}
			set
			{
				mModuleState = value;
			}
		}

		public bool IsAvailable
		{
			get
			{
				return mIsAvailable;
			}
			set
			{
				mIsAvailable = value;
			}
		}

		public bool IsDisplayed
		{
			get
			{
				return mIsDisplay;
			}
			set
			{
				mIsDisplay = value;
			}
		}

		public bool IsWithExperimentController
		{
			get
			{
				return mIsWithExperimentController;
			}
			set
			{
				mIsWithExperimentController = value;
			}
		}

		public List<int> TabIndexs
		{
			get
			{
				return mTabIndexs;
			}
			set
			{
				mTabIndexs = value;
			}
		}

		public int TabIndex
		{
			get
			{
				return mTabIndex;
			}
			set
			{
				mTabIndex = value;
			}
		}

		public List<string> CellSourceFileNames
		{
			get
			{
				return mCellSourceFileNames;
			}
			set
			{
				mCellSourceFileNames = value;
			}
		}

		public bool IsUseHotLid
		{
			get
			{
				return mIsUseHotLid;
			}
			set
			{
				mIsUseHotLid = value;
			}
		}

		public double HotLidSettingTemperature
		{
			get
			{
				return mHotLidSettingTemperature;
			}
			set
			{
				mHotLidSettingTemperature = value;
			}
		}

		public IRunningStatus RunningStatus
		{
			get
			{
				return mRunningStatus;
			}
			set
			{
				mRunningStatus = value;
			}
		}

		public bool IsWithAmplificationResult
		{
			get
			{
				return mIsWitAmplificationResult;
			}
			set
			{
				mIsWitAmplificationResult = value;
			}
		}

		public bool IsWithMeltingCurveResult
		{
			get
			{
				return mIsWithMeltingCurveResult;
			}
			set
			{
				mIsWithMeltingCurveResult = value;
			}
		}

		public bool IsContinueHRM
		{
			get
			{
				return mIsContinueHRM;
			}
		}

		public bool IsImportStandardCurve
		{
			get
			{
				return mIsImportStandardCurve;
			}
			set
			{
				mIsImportStandardCurve = value;
			}
		}

		public bool IsSkipDetectionSegment
		{
			get
			{
				return mIsSkipDetectionSegment;
			}
			set
			{
				mIsSkipDetectionSegment = value;
			}
		}

		public IPcrExperimentProject DefaultProject
		{
			get
			{
				return mDefaultProject;
			}
			set
			{
				mDefaultProject = value;
			}
		}

		public CurveColorStyle CurveColorStyle
		{
			get
			{
				return mCurveColorStyle;
			}
			set
			{
				mCurveColorStyle = value;
			}
		}

		public double SplitterVerticalRate
		{
			get
			{
				return mSplitterVerticalRate;
			}
			set
			{
				mSplitterVerticalRate = value;
			}
		}

		public double SplitterHorizontalRate
		{
			get
			{
				return mSplitterHorizontalRate;
			}
			set
			{
				mSplitterHorizontalRate = value;
			}
		}

		public bool RestartShowMeltingCurve
		{
			get
			{
				return mRestartShowMeltingCurve;
			}
			set
			{
				mRestartShowMeltingCurve = value;
			}
		}

		public bool RestartShowAmplificationCurve
		{
			get
			{
				return mRestartShowAmplificationCurve;
			}
			set
			{
				mRestartShowAmplificationCurve = value;
			}
		}

		public bool IsHideParameterPanel
		{
			get
			{
				return mIsHideParameterPanel;
			}
			set
			{
				mIsHideParameterPanel = value;
			}
		}

		public IApplication MainApplication
		{
			get
			{
				return mApplication;
			}
			set
			{
				mApplication = value;
			}
		}

		public string DefaultLabelString
		{
			get
			{
				return mDefaultLabelString;
			}
			set
			{
				mDefaultLabelString = value;
			}
		}

		public bool IsLabelSortIncrease
		{
			get
			{
				return mIsLabelSortIncrease;
			}
			set
			{
				mIsLabelSortIncrease = value;
			}
		}

		public int LabelStartValue
		{
			get
			{
				return mLabelStartValue;
			}
			set
			{
				mLabelStartValue = value;
			}
		}

		public int LabelInterval
		{
			get
			{
				return mLabelInterval;
			}
			set
			{
				mLabelInterval = value;
			}
		}

		public int LabelBits
		{
			get
			{
				return mLabelBits;
			}
			set
			{
				mLabelBits = value;
			}
		}

		public List<double> BlockTemperature
		{
			get
			{
				return mBlockTemperature;
			}
		}

		public List<double> HotLidTemperature
		{
			get
			{
				return mHotLidTemperature;
			}
		}

		public List<double> TubeTemperature
		{
			get
			{
				return mTubeTemperature;
			}
		}

		public Dictionary<string, IPcrStandardCurve> CurrentImportStandardCurve
		{
			get
			{
				return mCurrentImportStandardCurve;
			}
			set
			{
				mCurrentImportStandardCurve = value;
			}
		}

		public TemperatureControlType TemperatureControlType
		{
			get
			{
				return mTemperatureControlType;
			}
			set
			{
				mTemperatureControlType = value;
			}
		}

		public double TubeVolume
		{
			get
			{
				return mTubeVolume;
			}
			set
			{
				mTubeVolume = value;
			}
		}

		public bool IsDynamicAnalysis
		{
			get
			{
				return mIsDynamicAnalysis;
			}
			set
			{
				mIsDynamicAnalysis = value;
			}
		}

		public CellDisplaySortStyle CellDisplaySortStyle
		{
			get
			{
				return mCellDisplaySortStyle;
			}
			set
			{
				mCellDisplaySortStyle = value;
			}
		}

		public CellDisplaySortStyle MultiCellPlacementStyle
		{
			get
			{
				return mMultiCellPlacementStyle;
			}
			set
			{
				mMultiCellPlacementStyle = value;
			}
		}

		public bool AllProjectsReAnalysis
		{
			get
			{
				return mAllProjectsReAnalysis;
			}
			set
			{
				mAllProjectsReAnalysis = value;
			}
		}

		public bool IsChanged
		{
			get
			{
				return mIsChanged;
			}
			set
			{
				mIsChanged = value;
			}
		}

		private void CalculateHRMRamp()
		{
			try
			{
				if (mSystemType == PcrSystemType.GeneScan)
				{
					double startDegree = mPcrProgram.HRMSegments[0].StartDegree;
					double stopDegree = mPcrProgram.HRMSegments[0].StopDegree;
					int num = 0;
					int num2 = 0;
					for (int num3 = mBlockTemperature.Count - 1; num3 > 0; num3--)
					{
						if (stopDegree >= mBlockTemperature[num3])
						{
							num2 = num3;
							break;
						}
					}
					int num4 = num2;
					while (num4 > 0 && !(startDegree >= mBlockTemperature[num4]))
					{
						num++;
						num4--;
					}
					if (num != 0)
					{
						mHRMRamp = (stopDegree - startDegree) / (double)num;
						return;
					}
				}
				mHRMRamp = 0.0;
			}
			catch (Exception)
			{
				mHRMRamp = 0.0;
			}
		}

		public PcrExperiment(IPcrStructure pcrStructure)
		{
			mPcrStructure = pcrStructure;
			Initialize(pcrStructure.Application);
			mGuid = Guid.NewGuid();
			mSoftwareVersion = mConfigurationService.Version;
			mLightSacnStyle = LightScanStyle.ProjectChannel;
			mRunningStatus = new RunningStatus();
			mColumnList = new List<string>();
			mColumnConfiguration = new Dictionary<string, UltraGridColumn>();
			mTabIndexs = new List<int>();
			mCellSourceFileNames = new List<string>();
			mProjectProjerties = new List<IProjectProperty>();
			mProjects = new List<IPcrExperimentProject>();
			mSystemType = PcrSystemType.AbsoluteAnalysis;
			mIsWithExperimentController = false;
			mIsDynamicAnalysis = mConfigurationService.AnalysisConfiguration.IsDynamicAnalysis;
			RefreshColumnList();
			int num = 0;
			mIsChannelUsed = new bool[mPcrStructure.ChannelConfigurations.Length];
			IChannelConfiguration[] channelConfigurations = mPcrStructure.ChannelConfigurations;
			foreach (IChannelConfiguration channelConfiguration in channelConfigurations)
			{
				if (channelConfiguration != null)
				{
					mIsChannelUsed[num] = channelConfiguration.IsAvailable;
				}
				else
				{
					mIsChannelUsed[num] = false;
				}
				num++;
			}
			mSubModules = pcrStructure.GetAvailablePcrSubModules();
			foreach (ISubModule mSubModule in mSubModules)
			{
				AddSubModule(mSubModule);
			}
		}

		public void AddBlockTemperature(double temperature)
		{
			if (mBlockTemperature == null)
			{
				mBlockTemperature = new List<double>();
			}
			mBlockTemperature.Add(temperature);
		}

		public void AddHotLidTemperature(double temperature)
		{
			if (mHotLidTemperature == null)
			{
				mHotLidTemperature = new List<double>();
			}
			mHotLidTemperature.Add(temperature);
		}

		public void AddTubeTemperature(double temperature)
		{
			if (mTubeTemperature == null)
			{
				mTubeTemperature = new List<double>();
			}
			mTubeTemperature.Add(temperature);
		}

		public void Initialize(IApplication app)
		{
			mApplication = app;
			
			mConfigurationService = (IConfigurationService)app.GetService("ConfigurationService");
			
			mMiscService = (IMiscService)app.GetService("MiscService");
			
			mResourceManager = ResourceManager.CreateFileBasedResourceManager("PcrDataStructure", app.GetResourceFolder() + GetType().Namespace + "\\", null);
			
			mRuleEditorService = (IRuleEditorService)app.GetService("RuleEditorService");
			
			mAnalysisService = (IAnalysisService)app.GetService("AnalysisService");

			if (mProjects != null)
			{
				foreach (IPcrExperimentProject mProject in mProjects)
				{
					mProject.SetApplication(app);
				}
			}
			if (mPrintOptions == null)
			{
				mPrintOptions = new PrintOptions();
				mPrintOptions.DefaultReportTemplateFile = mConfigurationService.PrintConfiguration.DefaultReportTemplateFile;
				mPrintOptions.EachPageReportCount = mConfigurationService.PrintConfiguration.EachPageReportCount;
				mPrintOptions.PatientReportTitle = mConfigurationService.PrintConfiguration.PatientReportTitle;
			}
		}

		public void AddSubModule(ISubModule subModule)
		{
			int moduleIndex = subModule.PcrModule.GetModuleIndex();
			bool flag = false;
			foreach (IPcrModule mPcrModule in mPcrModules)
			{
				if (moduleIndex == mPcrModule.GetModuleIndex())
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				mPcrModules.Add(subModule.PcrModule);
				mModuleState = ((mPcrModules.Count != 1) ? PcrModuleState.Multiple : PcrModuleState.Single);
			}
			if (!mSubModules.Contains(subModule))
			{
				mSubModules.Add(subModule);
			}
		}

		public void UpdatePcrModuleStateBeforeExperiment()
		{
			List<IPcrModule> list = new List<IPcrModule>();
			foreach (IPcrModule mPcrModule in mPcrModules)
			{
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				foreach (ISubModule subModule in mPcrModule.SubModules)
				{
					if (subModule.IsAvailable())
					{
						num2++;
					}
					else if (!subModule.PcrExperiment.Equals(this))
					{
						num++;
					}
					else
					{
						num3++;
					}
				}
				if (num2 >= mPcrModule.SubModules.Count)
				{
					list.Add(mPcrModule);
					mPcrModule.CanbeUsed = true;
				}
				else if (num >= mPcrModule.SubModules.Count)
				{
					list.Add(mPcrModule);
					mPcrModule.CanbeUsed = false;
				}
				else if (num3 == 0)
				{
					list.Add(mPcrModule);
				}
				else
				{
					mPcrModule.CanbeUsed = false;
				}
			}
			foreach (IPcrModule item in list)
			{
				mPcrModules.Remove(item);
				foreach (ISubModule subModule2 in item.SubModules)
				{
					if (mSubModules.Contains(subModule2))
					{
						mSubModules.Remove(subModule2);
					}
				}
			}
		}

		public void RemoveSubModule(ISubModule subModule)
		{
			if (subModule.PcrExperiment != null && subModule.PcrExperiment.Equals(this))
			{
				subModule.PcrExperiment = null;
			}
			if (mSubModules.Contains(subModule))
			{
				mSubModules.Remove(subModule);
			}
		}

		public bool IsPcrCellIn(IPcrCell pcrCell)
		{
			if (pcrCell != null)
			{
				IPcrExperiment pcrExperiment = pcrCell.PcrExperiment;
				if (pcrExperiment != null)
				{
					return pcrExperiment.Name.CompareTo(mName) == 0;
				}
				return mSubModules.Contains(pcrCell.SubModule);
			}
			return false;
		}

		public bool CheckExperimentModuleCross(IPcrExperiment pcrExperiment)
		{
			foreach (ISubModule subModule in pcrExperiment.SubModules)
			{
				if (!subModule.IsBlank() && subModule.PcrExperiment.Equals(pcrExperiment) && mPcrModules.Contains(subModule.PcrModule))
				{
					return true;
				}
			}
			return false;
		}

		public List<IPcrCell> GetPcrCellsInExperiment()
		{
			int cellCount = mPcrStructure.GetCellCount();
			IPcrCell[] array = new IPcrCell[cellCount];
			List<IPcrCell> list = new List<IPcrCell>(cellCount);
			foreach (ISubModule mSubModule in mSubModules)
			{
				if (!CheckSubModuleIsInCurrentExperiment(mSubModule))
				{
					continue;
				}
				foreach (IPcrCell pcrCell in mSubModule.PcrCells)
				{
					int num = pcrCell.CellID - 1;
					array[num] = pcrCell;
				}
			}
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i] != null)
				{
					list.Add(array[i]);
				}
			}
			return list;
		}

		public List<ISubModule> CheckExperimentRemovedSubModules()
		{
			List<ISubModule> list = new List<ISubModule>();
			foreach (ISubModule mSubModule in mSubModules)
			{
				if (CheckSubModuleIsInCurrentExperiment(mSubModule) && mSubModule.IsBlank())
				{
					list.Add(mSubModule);
				}
			}
			return list;
		}

		public void ClearCellRealTimeCurve()
		{
			if (mPcrProgram.ALLDetectionCount <= 0)
			{
				return;
			}
			List<IPcrCell> pcrCellsInExperiment = GetPcrCellsInExperiment();
			foreach (IPcrCell item in pcrCellsInExperiment)
			{
				item.InitializeAnalysisDataList();
				item.ClearRawCurveSeries();
				item.ClearMeltingCurveSeries();
				item.ClearRealTimeAmplicationCurveSeries();
			}
		}

		public void RealTimeAnalyze()
		{
			IAnalysisService analysisService = (IAnalysisService)mPcrStructure.Application.GetService("AnalysisService");
			if (mStatus == PcrExperimentStatus.Running)
			{
				analysisService.RealTimeAnalyze(GetPcrCellsInExperiment());
				mRestartShowAmplificationCurve = true;
			}
		}

		private void SaveCellTemperature(string temperatureString)
		{
			StreamWriter streamWriter = null;
			try
			{
				streamWriter = new StreamWriter("C:\\temperature.txt", true);
				streamWriter.WriteLine(temperatureString);
			}
			catch (Exception)
			{
			}
			finally
			{
				if (streamWriter != null)
				{
					streamWriter.Close();
				}
			}
		}

		bool IPcrExperiment.Analyze()
		{
			try
			{
				if (mStatus == PcrExperimentStatus.AccomplishedSaved || mStatus == PcrExperimentStatus.AnalysisFailed || mStatus == PcrExperimentStatus.AnalysisAccomplished)
				{
					if (!RefreshCellTypeList())
					{
						return false;
					}
					if (CheckAllChannelBlank())
					{
						MessageBox.Show(mResourceManager.GetString("EmpetyCells"), mResourceManager.GetString("ErrorString"));
						return false;
					}
					if (mRunningStatus.DetectCycle < mConfigurationService.AnalysisConfiguration.MinCycleCount)
					{
						MessageBox.Show(mResourceManager.GetString("LessCycle") + mConfigurationService.AnalysisConfiguration.MinCycleCount + mResourceManager.GetString("ToAnalysisData"), mResourceManager.GetString("ErrorString"));
						mStatus = PcrExperimentStatus.AnalysisFailed;
						return false;
					}
					try
					{
						List<IPcrExperimentProject> list = null;
						list = CheckExperimentImportStandardCurve();
						if (list != null && list.Count > 0)
						{
							mAnalysisService.ShowImportStandardCurve(this, list, ref mCurrentImportStandardCurve, false);
							mIsImportStandardCurve = true;
						}
						else
						{
							mCurrentImportStandardCurve = null;
							mIsImportStandardCurve = false;
						}
						if (mCurrentImportStandardCurve != null && list != null)
						{
							foreach (IPcrExperimentProject item in list)
							{
								if (!mCellTypeLists.ContainsKey(item))
								{
									continue;
								}
								int length = mCellTypeLists[item].GetLength(0);
								int length2 = mCellTypeLists[item].GetLength(1);
								for (int i = 0; i < length; i++)
								{
									for (int j = 0; j < length2; j++)
									{
										if (!mCurrentImportStandardCurve.ContainsKey(item.Name))
										{
											continue;
										}
										List<IPcrCell> standardPcrCells = mCurrentImportStandardCurve[item.Name].GetStandardPcrCells(i, j);
										if (standardPcrCells == null)
										{
											continue;
										}
										mCellTypeLists[item][i, j].Add("ImportedStdCells", standardPcrCells);
										foreach (IPcrCell item2 in standardPcrCells)
										{
											item2.InitializeAnalysisDataList();
										}
									}
								}
							}
						}
						CalculateHRMRamp();
						if (ExecuteAnalyze(mAnalysisService.PreAnalyze) != 0)
						{
							mStatus = PcrExperimentStatus.AnalysisFailed;
							return false;
						}
					}
					catch (Exception)
					{
						mStatus = PcrExperimentStatus.AnalysisFailed;
						return false;
					}
					foreach (IPcrCell item3 in mPcrCellsInExperiment)
					{
						item3.CaculateLightCrossTalk(item3.Project ?? Projects[0]);
						item3.InitializeRuleCalculationValueCount();
						item3.InitializeMeltingResultDataCount();
					}
					if (ExecuteAnalyze(mAnalysisService.Analyze) == AnalysisError.NA)
					{
						mStatus = PcrExperimentStatus.AnalysisAccomplished;
						return true;
					}
					mStatus = PcrExperimentStatus.AnalysisFailed;
					return false;
				}
				return false;
			}
			catch
			{
				mStatus = PcrExperimentStatus.AnalysisFailed;
				throw;
			}
			finally
			{
				if (mPcrCellsInExperiment != null)
				{
					foreach (IPcrCell item4 in mPcrCellsInExperiment)
					{
						if (item4 != null)
						{
							item4.LoadLightRawData();
						}
					}
				}
			}
		}

		public void RefreshSubModulesBeforeNewFormClose()
		{
			foreach (ISubModule mSubModule in mSubModules)
			{
				mSubModule.PcrExperiment = null;
				foreach (IPcrCell pcrCell in mSubModule.PcrCells)
				{
					if (pcrCell.Project == null)
					{
						continue;
					}
					IChannelConfiguration[] channelConfigurations = pcrCell.Project.ChannelConfigurations;
					foreach (IChannelConfiguration channelConfiguration in channelConfigurations)
					{
						if (channelConfiguration.IsAvailable && channelConfiguration.IsSelected)
						{
							pcrCell.SetCellInformation("DetectionTypeKey", channelConfiguration.Position, string.Empty);
						}
					}
					pcrCell.Project = null;
				}
			}
		}

		public bool CheckIsWithSample()
		{
			if (mProjects == null)
			{
				return false;
			}
			if (mProjects.Count == 0)
			{
				return false;
			}
			string value = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[1];
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				if (mProject.Cells == null)
				{
					continue;
				}
				foreach (IPcrCell cell in mProject.Cells)
				{
					IProjectItem[] projectItems = mProject.ProjectItems;
					foreach (IProjectItem projectItem in projectItems)
					{
						if (projectItem != null)
						{
							int position = projectItem.ChannelConfiguration.Position;
							string cellInformation = cell.GetCellInformation("DetectionTypeKey", position);
							if (cellInformation.Equals(value))
							{
								return true;
							}
						}
					}
				}
			}
			return false;
		}

		public void InitializeExperimentCycleValue()
		{
			if (mPcrProgram.AmplificationDetectionCount > 0)
			{
				mAmplificationStartCycle = 1;
				mAmplificationStopCycle = mPcrProgram.AmplificationDetectionCount;
				mIsWitAmplificationResult = true;
			}
			else
			{
				mAmplificationStartCycle = 0;
				mAmplificationStopCycle = 0;
				mIsWitAmplificationResult = false;
			}
			if (mPcrProgram.MeltingDetectionCount > 0)
			{
				mMeltingStartCycle = mPcrProgram.AmplificationDetectionCount + 1;
				mMeltingStopCycle = mPcrProgram.AmplificationDetectionCount + mPcrProgram.MeltingDetectionCount;
				mIsWithMeltingCurveResult = true;
			}
			else
			{
				mMeltingStartCycle = 0;
				mMeltingStopCycle = 0;
				mIsWithMeltingCurveResult = false;
			}
		}

		void IPcrExperiment.InitializeCellLightDataList()
		{
			if (mPcrProgram == null || mPcrProgram.ALLDetectionCount <= 0)
			{
				return;
			}
			InitializeExperimentCycleValue();
			foreach (ISubModule mSubModule in mSubModules)
			{
				if (!(mSubModule is ExperimentSubModule))
				{
					continue;
				}
				foreach (IPcrCell pcrCell in mSubModule.PcrCells)
				{
					pcrCell.InitializeLightDataList(mPcrProgram.ALLDetectionCount, mConfigurationService.LightDataLength);
				}
			}
		}

		void IPcrExperiment.AddCellLightDataCount(int newDataCount)
		{
			if (mPcrProgram == null || mPcrProgram.ALLDetectionCount <= 0)
			{
				return;
			}
			InitializeExperimentCycleValue();
			foreach (ISubModule mSubModule in mSubModules)
			{
				if (!(mSubModule is ExperimentSubModule))
				{
					continue;
				}
				foreach (IPcrCell pcrCell in mSubModule.PcrCells)
				{
					pcrCell.AddLightDataList(mPcrProgram.ALLDetectionCount, mConfigurationService.LightDataLength);
				}
			}
		}

		public void AddColumn(UltraGridColumn gridColumn)
		{
			if (!mColumnConfiguration.ContainsKey(gridColumn.Key))
			{
				mColumnConfiguration.Add(gridColumn.Key, gridColumn);
				mColumnList.Add(gridColumn.Key);
			}
		}

		public void RemoveColumn(string name)
		{
			if (mColumnConfiguration.ContainsKey(name))
			{
				mColumnConfiguration.Remove(name);
				mColumnList.Remove(name);
			}
		}

		public UltraGridColumn GetColumn(string name)
		{
			if (mColumnConfiguration.ContainsKey(name))
			{
				return mColumnConfiguration[name];
			}
			return null;
		}

		public UltraGridColumn[] GetGridColumnArray()
		{
			UltraGridColumn[] array = new UltraGridColumn[mColumnConfiguration.Count];
			mColumnConfiguration.Values.CopyTo(array, 0);
			return array;
		}

		public void SaveCellMainDisplayTable(UltraDataSource informationTable, ColumnsCollection gridColumns)
		{
			mColumnList = new List<string>();
			foreach (UltraGridColumn gridColumn in gridColumns)
			{
				mColumnList.Add(gridColumn.Key);
			}
			foreach (UltraDataRow item in (IEnumerable)informationTable.Rows)
			{
				int num = Convert.ToInt32(item["CellIDKey"]) - 1;
				int channelIndex = Convert.ToInt32(item["ChannelKey"]) - 1;
				if (num < 0)
				{
					break;
				}
				IPcrCell pcrCell = item.Tag as PcrCell;
				foreach (string mColumn in mColumnList)
				{
					if (pcrCell != null)
					{
						pcrCell.SetCellInformation(mColumn, channelIndex, item[mColumn].ToString());
					}
				}
			}
		}

		public int GetAllPcrCellCountWithProject()
		{
			int num = 0;
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				num += mProject.Cells.Count;
			}
			return num;
		}

		public virtual void CheckNewColumnExist()
		{
			if (!mColumnConfiguration.ContainsKey("InterpretationKey"))
			{
				mColumnConfiguration.Add("InterpretationKey", mConfigurationService.ColumnConfiguration["InterpretationKey"]);
				int num = mColumnList.IndexOf("LightCVKey");
				mColumnList.Insert(num + 1, "InterpretationKey");
			}
			if (!mColumnList.Contains("InterpretationColorKey"))
			{
				mColumnList.Add("InterpretationColorKey");
			}
			if (!mColumnConfiguration.ContainsKey("InterpretationColorKey"))
			{
				mColumnConfiguration.Add("InterpretationColorKey", mConfigurationService.ColumnConfiguration["InterpretationColorKey"]);
			}
			if (mColumnList.Contains("RuleCalculationKey1"))
			{
				return;
			}
			int num2 = mColumnList.IndexOf("InterpretationKey") + 1;
			for (int i = 1; i <= 10; i++)
			{
				if (!mColumnConfiguration.ContainsKey("RuleCalculationKey" + i))
				{
					mColumnConfiguration.Add("RuleCalculationKey" + i, mConfigurationService.ColumnConfiguration["RuleCalculationKey" + i]);
				}
				mColumnList.Insert(num2++, "RuleCalculationKey" + i);
			}
		}

		public void ClearCellRowIndex()
		{
			List<IPcrCell> pcrCellsInExperiment = GetPcrCellsInExperiment();
			for (int i = 0; i < pcrCellsInExperiment.Count; i++)
			{
				pcrCellsInExperiment[i].DataRowIndex = -1;
			}
		}

		public UltraDataSource CreateCellMainDisplayTable(UltraDataSource oldTable)
		{
			bool flag = false;
			if (oldTable == null)
			{
				mCellGridDataSource = new UltraDataSource();
				for (int i = 0; i < mColumnList.Count; i++)
				{
					mCellGridDataSource.Band.Columns.Add(mColumnList[i]);
				}
			}
			else
			{
				mCellGridDataSource = oldTable;
				mCellGridDataSource.Rows.Clear();
			}
			bool[] array = mIsChannelUsed;
			List<IPcrCell> pcrCellsInExperiment = GetPcrCellsInExperiment();
			for (int j = 0; j < pcrCellsInExperiment.Count; j++)
			{
				int num = -1;
				object[] array2 = new object[mCellGridDataSource.Band.Columns.Count];
				for (int k = 0; k < array.Length; k++)
				{
					if (!array[k])
					{
						continue;
					}
					array2[0] = j + 1;
					for (int l = 1; l < array2.Length; l++)
					{
						string key = mCellGridDataSource.Band.Columns[l].Key;
						array2[l] = pcrCellsInExperiment[j].GetCellInformation(key, k);
						if (key.Equals("DetectionTypeKey") && array2[l].Equals("Unkown"))
						{
							array2[l] = "Unknown";
							pcrCellsInExperiment[j].SetCellInformation("DetectionTypeKey", k, "Unknown");
						}
						if (key.Equals("PropertyKey"))
						{
							string cellInformation = pcrCellsInExperiment[j].GetCellInformation("DetectionTypeKey", k);
							if (cellInformation.Equals(AbsoluteDetectionType.Standard.ToString()) || cellInformation.Equals(AbsoluteDetectionType.QC.ToString()))
							{
								array2[l] = mMiscService.ConvertScientificString(array2[l].ToString(), mConfigurationService.AnalysisConfiguration.ConcentrationFormatString);
							}
						}
						if (!flag && key.Equals("ReplicatedTubeKey") && !string.IsNullOrEmpty(array2[l].ToString()))
						{
							flag = true;
						}
					}
					UltraDataRow ultraDataRow = mCellGridDataSource.Rows.Add(array2);
					ultraDataRow.Tag = pcrCellsInExperiment[j];
					if (num < 0)
					{
						num = ultraDataRow.Index;
					}
				}
				pcrCellsInExperiment[j].DataRowIndex = -1;
			}
			mCellGridDataSource.Band.Columns["ReplicatedTubeKey"].Tag = flag;
			return mCellGridDataSource;
		}

		public UltraDataSource CreateCellInformationTable()
		{
			string value = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[1];
			UltraDataSource ultraDataSource = new UltraDataSource();
			ultraDataSource.Band.Columns.Add("CellPositionKey");
			ultraDataSource.Band.Columns.Add("ChannelKey");
			ultraDataSource.Band.Columns.Add("ProjectNameKey");
			for (int i = 0; i < mColumnList.Count; i++)
			{
				UltraGridColumn ultraGridColumn = mColumnConfiguration[mColumnList[i]];
				IColumn column = ultraGridColumn.Tag as IColumn;
				if (column == null || column.Classification == ColumnClassification.PatientInformation || column.Classification == ColumnClassification.CustomInformation)
				{
					ultraDataSource.Band.Columns.Add(mColumnList[i]);
				}
			}
			List<IPcrCell> pcrCellsInExperiment = GetPcrCellsInExperiment();
			for (int j = 0; j < pcrCellsInExperiment.Count; j++)
			{
				if (pcrCellsInExperiment[j].Project == null)
				{
					continue;
				}
				int num = -1;
				IChannelConfiguration[] channelConfigurations = pcrCellsInExperiment[j].Project.ChannelConfigurations;
				for (int k = 0; k < channelConfigurations.Length; k++)
				{
					if (channelConfigurations[k].IsAvailable && channelConfigurations[k].IsSelected)
					{
						string cellInformation = pcrCellsInExperiment[j].GetCellInformation("DetectionTypeKey", k);
						if (cellInformation.Equals(value))
						{
							num = k;
						}
					}
				}
				if (num >= 0)
				{
					object[] array = new object[ultraDataSource.Band.Columns.Count];
					for (int l = 0; l < array.Length; l++)
					{
						string key = ultraDataSource.Band.Columns[l].Key;
						array[l] = pcrCellsInExperiment[j].GetCellInformation(key, num);
					}
					UltraDataRow ultraDataRow = ultraDataSource.Rows.Add(array);
					ultraDataRow.Tag = pcrCellsInExperiment[j];
				}
			}
			return ultraDataSource;
		}

		public void SaveCellInformationTable(UltraDataSource informationTable)
		{
			foreach (UltraDataRow item in (IEnumerable)informationTable.Rows)
			{
				if (item["ChannelKey"].ToString().Equals("00"))
				{
					continue;
				}
				IPcrCell pcrCell = item.Tag as IPcrCell;
				if (pcrCell == null)
				{
					continue;
				}
				IChannelConfiguration[] channelConfigurations;
				if (pcrCell.Project != null)
				{
					channelConfigurations = pcrCell.Project.ChannelConfigurations;
				}
				else
				{
					if (mProjects == null || mProjects.Count <= 0)
					{
						continue;
					}
					channelConfigurations = mProjects[0].ChannelConfigurations;
				}
				for (int i = 0; i < channelConfigurations.Length; i++)
				{
					if (!channelConfigurations[i].IsAvailable || !channelConfigurations[i].IsSelected)
					{
						continue;
					}
					for (int j = 2; j < item.Band.Columns.Count; j++)
					{
						string key = informationTable.Band.Columns[j].Key;
						if (pcrCell.MultiTubeCells == null)
						{
							pcrCell.MultiTubeCells = new List<IPcrCell> { pcrCell };
						}
						foreach (IPcrCell multiTubeCell in pcrCell.MultiTubeCells)
						{
							multiTubeCell.SetCellInformation(key, i, item[j].ToString());
						}
					}
				}
			}
		}

		public void RefreshCellInforamtionInMainDisplayTable(UltraDataSource oldTable)
		{
		}

		public int GetAvailableChannelCount()
		{
			mAvailableChannelAmount = 0;
			bool[] array = mIsChannelUsed;
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i])
				{
					mAvailableChannelAmount++;
				}
			}
			return mAvailableChannelAmount;
		}

		public virtual bool RefreshCellTypeList()
		{
			RefreshChannelUsed();
			string[] detectionTypeArray = mConfigurationService.GetDetectionTypeArray(mSystemType);
			mCellTypeLists = new Dictionary<IPcrExperimentProject, Dictionary<string, List<IPcrCell>>[,]>();
			if (mAnalysisResults == null)
			{
				mAnalysisResults = new Dictionary<IPcrExperimentProject, IAnalysisResult[,]>();
			}
			mAnalysisResults.Clear();
			mProjectThresholdCurves = new Dictionary<IPcrExperimentProject, XYSeries[,]>();
			IGeneScanPcrExperimentProject geneScanPcrExperimentProject = mProjects[0] as IGeneScanPcrExperimentProject;
			mIsContinueHRM = false;
			if (mSystemType == PcrSystemType.GeneScan && geneScanPcrExperimentProject != null)
			{
				mIsContinueHRM = geneScanPcrExperimentProject.HRMMode == HRMModeEnum.Continue;
			}
			InitializeMeltingVariables();
			mPcrCellsInExperiment = GetPcrCellsInExperiment();
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				int tubeCount = mProject.TubeCount;
				int num = mProject.ChannelConfigurations.Length;
				if (!mAnalysisResults.ContainsKey(mProject))
				{
					mAnalysisResults.Add(mProject, new IAnalysisResult[num, tubeCount]);
				}
				Dictionary<string, List<IPcrCell>>[,] array = new Dictionary<string, List<IPcrCell>>[num, tubeCount];
				IProjectItem[] projectItems = mProject.ProjectItems;
				foreach (IProjectItem projectItem in projectItems)
				{
					if (projectItem == null || !projectItem.ChannelConfiguration.IsAvailable || !projectItem.ChannelConfiguration.IsSelected)
					{
						continue;
					}
					for (int j = 0; j < tubeCount; j++)
					{
						array[projectItem.ChannelConfiguration.Position, j] = new Dictionary<string, List<IPcrCell>>();
						for (int k = 0; k < detectionTypeArray.Length; k++)
						{
							if (!string.IsNullOrEmpty(detectionTypeArray[k]))
							{
								array[projectItem.ChannelConfiguration.Position, j].Add(detectionTypeArray[k], new List<IPcrCell>());
							}
						}
					}
				}
				mCellTypeLists.Add(mProject, array);
				foreach (IPcrCell cell in mProject.Cells)
				{
					cell.InitializeAnalysisDataList();
					IProjectItem[] projectItems2 = mProject.ProjectItems;
					foreach (IProjectItem projectItem2 in projectItems2)
					{
						if (projectItem2 == null || !projectItem2.ChannelConfiguration.IsAvailable || !projectItem2.ChannelConfiguration.IsSelected)
						{
							continue;
						}
						int position = projectItem2.ChannelConfiguration.Position;
						ClearResultInformation(cell, position);
						bool flag = false;
						string text = cell.GetCellInformation("DetectionTypeKey", position).Trim();
						string text2 = cell.GetCellInformation("DetectionProjectKey", position).Trim();
						if (text.Length == 0 || text.CompareTo(detectionTypeArray[6]) == 0)
						{
							flag = true;
						}
						else
						{
							if (text2.Length == 0)
							{
								MessageBox.Show(cell.CellPosition + mResourceManager.GetString("ChannelString") + (position + 1) + mResourceManager.GetString("DetectionProjectEmpty"), mResourceManager.GetString("ErrorString"));
								return false;
							}
							if (text.CompareTo(mResourceManager.GetString("StandardString")) == 0 && !CheckStandardCell(cell, position))
							{
								return false;
							}
						}
						if (flag)
						{
							text = detectionTypeArray[6];
							cell.SetCellInformation("DetectionTypeKey", position, text);
						}
						else
						{
							if (cell.IsBad)
							{
								continue;
							}
							bool flag2 = false;
							for (int m = 0; m < tubeCount; m++)
							{
								if (text2.Equals(projectItem2.TubeAnalysisParameterConfiguration[m].ProjectName))
								{
									if (!array[position, m].ContainsKey(text))
									{
										List<IPcrCell> list = new List<IPcrCell>();
										list.Add(cell);
										array[position, m].Add(text, list);
									}
									else
									{
										array[position, m][text].Add(cell);
									}
									flag2 |= projectItem2.TubeAnalysisParameterConfiguration[m].IsNeedReAnalysis;
								}
							}
							IAnalysisService analysisService = (IAnalysisService)mPcrStructure.Application.GetService("AnalysisService");
							analysisService.SetProjectNeedAnalysis(flag2 | cell.GetIsNeedAnalysis(projectItem2.ChannelConfiguration.Position), mProject);
						}
					}
					Application.DoEvents();
				}
				XYSeries[,] array2 = new XYSeries[num, tubeCount];
				XYSeries[,] array3 = null;
				XYSeries[,] array4 = null;
				XYSeries[,] array5 = null;
				XYSeries xYSeries = null;
				XYSeries xYSeries2 = null;
				XYSeries xYSeries3 = null;
				XYSeries xYSeries4 = null;
				bool flag3 = false;
				bool flag4 = false;
				IMeltingSegment meltingSegment = mProject.PcrProgram.GetMeltingSegment(0);
				if (mProject.SystemType == PcrSystemType.AbsoluteAnalysis && meltingSegment != null && meltingSegment.IsAvailable)
				{
					flag3 = true;
					array3 = new XYSeries[num, tubeCount];
					array4 = new XYSeries[num, tubeCount];
					array5 = new XYSeries[num, tubeCount];
				}
				else if (mProject.SystemType == PcrSystemType.GeneScan)
				{
					flag4 = true;
				}
				int num2 = 0;
				IProjectItem[] projectItems3 = mProject.ProjectItems;
				foreach (IProjectItem projectItem3 in projectItems3)
				{
					if (projectItem3 == null || string.IsNullOrEmpty(projectItem3.Name) || !projectItem3.ChannelConfiguration.IsSelected || !projectItem3.ChannelConfiguration.IsAvailable)
					{
						continue;
					}
					for (int num3 = 0; num3 < tubeCount; num3++)
					{
						string projectName = projectItem3.TubeAnalysisParameterConfiguration[num3].ProjectName;
						IAbsoluteAnalysisParameterConfiguration absoluteAnalysisParameterConfiguration = projectItem3.TubeAnalysisParameterConfiguration[num3] as IAbsoluteAnalysisParameterConfiguration;
						int position = projectItem3.ChannelConfiguration.Position;
						array2[position, num3] = CreateThresholdLine(absoluteAnalysisParameterConfiguration.ManualThreshold, projectName);
						array2[position, num3].Key = "ThresholdCurve" + num2;
						if (flag3)
						{
							IMeltingAnalysisParameterConfiguration meltingAnalysisParameterConfiguration = projectItem3.TubeMeltingAnalysisParameterConfiguration[num3] as IMeltingAnalysisParameterConfiguration;
							array3[position, num3] = CreateMeltingThresholdLine(meltingAnalysisParameterConfiguration.NoiseThreshold, projectName, meltingSegment);
							array3[position, num3].Key = "Melting ThresholdCurve" + num2;
							array4[position, num3] = CreateMeltingTemperatureLine(meltingAnalysisParameterConfiguration.MinTemperature, projectName, Color.Red);
							array4[position, num3].Key = "Melting Min Temperature" + num2;
							array5[position, num3] = CreateMeltingTemperatureLine(meltingAnalysisParameterConfiguration.MaxTemperature, projectName, Color.Red);
							array5[position, num3].Key = "Melting Max Temperature" + num2;
						}
						else if (flag4)
						{
							IHRMAnalysisParameterConfiguration iHRMAnalysisParameterConfiguration = projectItem3.TubeMeltingAnalysisParameterConfiguration[num3] as IHRMAnalysisParameterConfiguration;
							xYSeries = CreateMeltingTemperatureLine(iHRMAnalysisParameterConfiguration.StartTemperatureBeforeMelting, projectName, Color.Red);
							xYSeries.Key = "StartTemperatureBeforeMelting";
							xYSeries2 = CreateMeltingTemperatureLine(iHRMAnalysisParameterConfiguration.StopTemperatureBeforeMelting, projectName, Color.Red);
							xYSeries2.Key = "StopTemperatureBeforeMelting";
							xYSeries3 = CreateMeltingTemperatureLine(iHRMAnalysisParameterConfiguration.StartTemperatureAfterMelting, projectName, Color.Blue);
							xYSeries3.Key = "StartTemperatureAfterMelting";
							xYSeries4 = CreateMeltingTemperatureLine(iHRMAnalysisParameterConfiguration.StopTemperatureAfterMelting, projectName, Color.Blue);
							xYSeries4.Key = "StopTemperatureAfterMelting";
						}
						num2++;
					}
				}
				mProjectThresholdCurves.Add(mProject, array2);
				if (flag3)
				{
					if (mMeltingThresholdCurves != null)
					{
						mMeltingThresholdCurves.Add(mProject, array3);
					}
					if (mMeltingMinTemperatureCurves != null)
					{
						mMeltingMinTemperatureCurves.Add(mProject, array4);
					}
					if (mMeltingMaxTemperatureCurves != null)
					{
						mMeltingMaxTemperatureCurves.Add(mProject, array5);
					}
				}
				else if (flag4)
				{
					mHRMBeforeMeltingStartCurves.Add(mProject, xYSeries);
					mHRMBeforeMeltingStopCurves.Add(mProject, xYSeries2);
					mHRMAfterMeltingStartCurves.Add(mProject, xYSeries3);
					mHRMAfterMeltingStopCurves.Add(mProject, xYSeries4);
				}
			}
			return true;
		}

		public void DisplayThresholdCurves(IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInVisible)
		{
			try
			{
				if (mProjectThresholdCurves == null || !mProjectThresholdCurves.ContainsKey(project))
				{
					return;
				}
				if (setCurvesInVisible)
				{
					IEnumerator enumerator = mProjectThresholdCurves.Keys.GetEnumerator();
					while (enumerator.MoveNext())
					{
						IPcrExperimentProject pcrExperimentProject = (IPcrExperimentProject)enumerator.Current;
						if (pcrExperimentProject == null)
						{
							continue;
						}
						XYSeries[,] array = mProjectThresholdCurves[pcrExperimentProject];
						foreach (XYSeries xYSeries in array)
						{
							if (xYSeries != null)
							{
								xYSeries.Visible = false;
							}
						}
					}
				}
				XYSeries xYSeries2 = mProjectThresholdCurves[project][channelIndex, targetIndex];
				if (xYSeries2 != null)
				{
					xYSeries2.Visible = isDisplay;
				}
			}
			catch (Exception)
			{
			}
		}

		public void DisplayMeltingThresholdCurves(IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInVisible)
		{
			try
			{
				if (mMeltingThresholdCurves == null || !mMeltingThresholdCurves.ContainsKey(project))
				{
					return;
				}
				if (setCurvesInVisible)
				{
					XYSeries[,] array = mMeltingThresholdCurves[project];
					foreach (XYSeries xYSeries in array)
					{
						if (xYSeries != null)
						{
							xYSeries.Visible = false;
						}
					}
				}
				XYSeries xYSeries2 = mMeltingThresholdCurves[project][channelIndex, targetIndex];
				if (xYSeries2 != null)
				{
					xYSeries2.Visible = isDisplay;
				}
			}
			catch (Exception)
			{
			}
		}

		public void DisplayMeltingMinTemperatureCurves(IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInVisible)
		{
			try
			{
				if (mMeltingMinTemperatureCurves == null || !mMeltingMinTemperatureCurves.ContainsKey(project))
				{
					return;
				}
				if (setCurvesInVisible)
				{
					XYSeries[,] array = mMeltingMinTemperatureCurves[project];
					foreach (XYSeries xYSeries in array)
					{
						if (xYSeries != null)
						{
							xYSeries.Visible = false;
						}
					}
				}
				XYSeries xYSeries2 = mMeltingMinTemperatureCurves[project][channelIndex, targetIndex];
				if (xYSeries2 != null)
				{
					xYSeries2.Visible = isDisplay;
				}
			}
			catch (Exception)
			{
			}
		}

		public void DisplayMeltingMaxTemperatureCurves(IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInVisible)
		{
			try
			{
				if (mMeltingMaxTemperatureCurves == null || !mMeltingMaxTemperatureCurves.ContainsKey(project))
				{
					return;
				}
				if (setCurvesInVisible)
				{
					XYSeries[,] array = mMeltingMaxTemperatureCurves[project];
					foreach (XYSeries xYSeries in array)
					{
						if (xYSeries != null)
						{
							xYSeries.Visible = false;
						}
					}
				}
				XYSeries xYSeries2 = mMeltingMaxTemperatureCurves[project][channelIndex, targetIndex];
				if (xYSeries2 != null)
				{
					xYSeries2.Visible = isDisplay;
				}
			}
			catch (Exception)
			{
			}
		}

		public void RefreshThresholdCurveLine(double value, IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInvisible)
		{
			XYSeries[,] thresholdCurves = GetThresholdCurves(project);
			if (thresholdCurves == null || channelIndex < 0 || channelIndex > thresholdCurves.Length)
			{
				return;
			}
			if (thresholdCurves[channelIndex, targetIndex] != null)
			{
				foreach (XYDataPoint point in thresholdCurves[channelIndex, targetIndex].Points)
				{
					point.ValueY = value;
				}
			}
			DisplayThresholdCurves(project, channelIndex, targetIndex, isDisplay, setCurvesInvisible);
		}

		public void RefreshMeltingThresholdCurveLine(double value, IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInvisible)
		{
			XYSeries[,] meltingThresholdCurves = GetMeltingThresholdCurves(project);
			if (meltingThresholdCurves == null || channelIndex < 0 || channelIndex > meltingThresholdCurves.Length)
			{
				return;
			}
			if (meltingThresholdCurves[channelIndex, targetIndex] != null)
			{
				foreach (XYDataPoint point in meltingThresholdCurves[channelIndex, targetIndex].Points)
				{
					point.ValueY = value;
				}
			}
			DisplayMeltingThresholdCurves(project, channelIndex, targetIndex, isDisplay, setCurvesInvisible);
		}

		public void RefreshMeltingMinTemperatureCurveLine(double value, IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInvisible)
		{
			XYSeries[,] meltingMinTemperatureCurves = GetMeltingMinTemperatureCurves(project);
			if (meltingMinTemperatureCurves == null || channelIndex < 0 || channelIndex > meltingMinTemperatureCurves.Length)
			{
				return;
			}
			if (meltingMinTemperatureCurves[channelIndex, targetIndex] != null)
			{
				foreach (XYDataPoint point in meltingMinTemperatureCurves[channelIndex, targetIndex].Points)
				{
					point.ValueX = value;
				}
			}
			DisplayMeltingMinTemperatureCurves(project, channelIndex, targetIndex, isDisplay, setCurvesInvisible);
		}

		public void RefreshMeltingMaxTemperatureCurveLine(double value, IPcrExperimentProject project, int channelIndex, int targetIndex, bool isDisplay, bool setCurvesInvisible)
		{
			XYSeries[,] meltingMaxTemperatureCurves = GetMeltingMaxTemperatureCurves(project);
			if (meltingMaxTemperatureCurves == null || channelIndex < 0 || channelIndex > meltingMaxTemperatureCurves.Length)
			{
				return;
			}
			if (meltingMaxTemperatureCurves[channelIndex, targetIndex] != null)
			{
				foreach (XYDataPoint point in meltingMaxTemperatureCurves[channelIndex, targetIndex].Points)
				{
					point.ValueX = value;
				}
			}
			DisplayMeltingMaxTemperatureCurves(project, channelIndex, targetIndex, isDisplay, setCurvesInvisible);
		}

		public XYSeries[,] GetThresholdCurves(IPcrExperimentProject project)
		{
			try
			{
				if (!mProjectThresholdCurves.ContainsKey(project))
				{
					return null;
				}
				return mProjectThresholdCurves[project];
			}
			catch (Exception)
			{
				return null;
			}
		}

		public XYSeries[,] GetMeltingThresholdCurves(IPcrExperimentProject project)
		{
			try
			{
				if (mMeltingThresholdCurves == null)
				{
					return null;
				}
				if (!mMeltingThresholdCurves.ContainsKey(project))
				{
					return null;
				}
				return mMeltingThresholdCurves[project];
			}
			catch (Exception)
			{
				return null;
			}
		}

		public XYSeries[,] GetMeltingMinTemperatureCurves(IPcrExperimentProject project)
		{
			try
			{
				if (mMeltingMinTemperatureCurves == null)
				{
					return null;
				}
				if (!mMeltingMinTemperatureCurves.ContainsKey(project))
				{
					return null;
				}
				return mMeltingMinTemperatureCurves[project];
			}
			catch (Exception)
			{
				return null;
			}
		}

		public XYSeries[,] GetMeltingMaxTemperatureCurves(IPcrExperimentProject project)
		{
			try
			{
				if (mMeltingMaxTemperatureCurves == null)
				{
					return null;
				}
				if (!mMeltingMaxTemperatureCurves.ContainsKey(project))
				{
					return null;
				}
				return mMeltingMaxTemperatureCurves[project];
			}
			catch (Exception)
			{
				return null;
			}
		}

		public BoxAnnotation[] GetThresholdAnnotations(IPcrExperimentProject project)
		{
			return null;
		}

		public IAbsoluteAnalysisParameterConfiguration GetAnalysisOptions(string projectName, int channelIndex)
		{
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				if (mProject.Name.Equals(projectName) && channelIndex < mProject.AnalysisParameterConfigurationList.Count)
				{
					return mProject.AnalysisParameterConfigurationList[channelIndex] as IAbsoluteAnalysisParameterConfiguration;
				}
			}
			return null;
		}

		public bool[] RefreshChannelUsed()
		{
			mAvailableChannelAmount = 0;
			for (int i = 0; i < mIsChannelUsed.Length; i++)
			{
				mIsChannelUsed[i] = false;
			}
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				IProjectItem[] projectItems = mProject.ProjectItems;
				foreach (IProjectItem projectItem in projectItems)
				{
					if (projectItem != null && !string.IsNullOrEmpty(projectItem.Name))
					{
						IChannelConfiguration channelConfiguration = projectItem.ChannelConfiguration;
						if (projectItem.ChannelConfiguration.IsSelected && projectItem.ChannelConfiguration.IsAvailable)
						{
							mIsChannelUsed[channelConfiguration.Position] = true;
						}
					}
				}
			}
			for (int k = 0; k < mIsChannelUsed.Length; k++)
			{
				mPcrStructure.ChannelConfigurations[k].IsAvailable = mIsChannelUsed[k];
				mPcrStructure.ChannelConfigurations[k].IsSelected = mIsChannelUsed[k];
				if (mIsChannelUsed[k])
				{
					mAvailableChannelAmount++;
				}
			}
			return mIsChannelUsed;
		}

		public bool FindSameProject(IPcrExperimentProject newProject, ref IPcrExperimentProject experimentProject)
		{
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				if (mProject.IsProjectSame(newProject))
				{
					experimentProject = mProject;
					return true;
				}
			}
			experimentProject = null;
			return false;
		}

		public void ExportRawDataToExcel(int cycle, string fileName)
		{
			try
			{
				Workbook workbook = new Workbook();
				Worksheet[] array = new Worksheet[mConfigurationService.ChannelCount];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = workbook.Worksheets.Add(mResourceManager.GetString("ChannelString") + (i + 1));
				}
				foreach (ISubModule mSubModule in mSubModules)
				{
					foreach (IPcrCell pcrCell in mSubModule.PcrCells)
					{
						int row;
						int column;
						if (GetCellRowColumnIndex(pcrCell, out row, out column))
						{
							for (int j = 0; j < array.Length; j++)
							{
								double num = pcrCell.GetRawData(j, cycle);
								if (num.CompareTo(double.NaN) == 0)
								{
									num = 0.0;
								}
								array[j].Rows[row - 1].Cells[column - 1].Value = num;
							}
						}
						Application.DoEvents();
					}
				}
				workbook.Save(fileName);
			}
			catch (Exception)
			{
			}
		}

		public bool CheckCellSubModuleInPcrExperiment(IPcrCell pcrCell)
		{
			foreach (ISubModule mSubModule in mSubModules)
			{
				if (mSubModule.PcrCells.Contains(pcrCell))
				{
					return true;
				}
			}
			return false;
		}

		public List<string> GenerateColumnListFromConfiguration(Dictionary<string, UltraGridColumn> columnConfiguration)
		{
			string[] array = new string[columnConfiguration.Count];
			columnConfiguration.Keys.CopyTo(array, 0);
			return new List<string>(array);
		}

		public void SetAnalysisResult(IPcrExperimentProject project, int channelIndex, int targetIndex, IAnalysisResult analysisResult)
		{
			if (mAnalysisResults.ContainsKey(project) && channelIndex < mAnalysisResults[project].Length)
			{
				mAnalysisResults[project][channelIndex, targetIndex] = analysisResult;
				analysisResult.Project = project;
			}
		}

		public IAnalysisResult GetAnalysisResult(IPcrExperimentProject project, int channelIndex, int targetIndex)
		{
			if (!mAnalysisResults.ContainsKey(project))
			{
				return null;
			}
			if (channelIndex < mAnalysisResults[project].Length)
			{
				return mAnalysisResults[project][channelIndex, targetIndex];
			}
			return null;
		}

		public IAnalysisResult[,] GetAnalysisResults(IPcrExperimentProject project)
		{
			if (!mAnalysisResults.ContainsKey(project))
			{
				return null;
			}
			return mAnalysisResults[project];
		}

		public void RefreshColumnList()
		{
			mColumnConfiguration = mConfigurationService.CopyColumnConfiguration(true, mConfigurationService.ColumnConfiguration, mSystemType);
			IEnumerator<string> enumerator = mColumnConfiguration.Keys.GetEnumerator();
			List<string> list = new List<string>();
			while (enumerator.MoveNext())
			{
				if (enumerator.Current != null)
				{
					UltraGridColumn ultraGridColumn = mColumnConfiguration[enumerator.Current];
					IColumn column = ultraGridColumn.Tag as IColumn;
					if (!CheckColumnInExperiment(column))
					{
						list.Add(enumerator.Current);
					}
				}
			}
			foreach (string item in list)
			{
				mColumnConfiguration.Remove(item);
			}
			mColumnList = GenerateColumnListFromConfiguration(mColumnConfiguration);
		}

		protected virtual bool CheckStandardCell(IPcrCell pcrCell, int channelIndex)
		{
			try
			{
				string text = pcrCell.GetCellInformation("PropertyKey", channelIndex).Trim();
				if (text.Length == 0)
				{
					MessageBox.Show(pcrCell.CellPosition + mResourceManager.GetString("ChannelString") + (channelIndex + 1) + mResourceManager.GetString("ConcentrationEmpty"), mResourceManager.GetString("ErrorString"));
					return false;
				}
				int num = int.Parse(text);
				if (num <= 0)
				{
					MessageBox.Show(pcrCell.CellPosition + mResourceManager.GetString("ChannelString") + (channelIndex + 1) + mResourceManager.GetString("ConcentrationLargerThanZero"), mResourceManager.GetString("ErrorString"));
					return false;
				}
				return true;
			}
			catch (Exception)
			{
				MessageBox.Show(pcrCell.CellPosition + mResourceManager.GetString("ChannelString") + (channelIndex + 1) + mResourceManager.GetString("ConcentrationValid"), mResourceManager.GetString("ErrorString"));
				return false;
			}
		}

		protected virtual void ClearResultInformation(IPcrCell pcrCell, int channelIndex)
		{
			pcrCell.SetCellInformation("InterpretationKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("AverageConcentrationKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("LightCVKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("CVValueKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("MeasurementResultKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("CycleValueKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("MeltingResultKey", channelIndex, string.Empty);
			pcrCell.SetCellInformation("MeltingTemperatureKey", channelIndex, string.Empty);
			for (int i = 0; i < 10; i++)
			{
				pcrCell.SetCellInformation("MeltingTemperatureKey" + (i + 1), channelIndex, string.Empty);
				pcrCell.SetCellInformation("RuleCalculationKey" + (i + 1), channelIndex, string.Empty);
			}
		}

		protected virtual void InitializeMeltingVariables()
		{
			mMeltingThresholdCurves = new Dictionary<IPcrExperimentProject, XYSeries[,]>();
			mMeltingMinTemperatureCurves = new Dictionary<IPcrExperimentProject, XYSeries[,]>();
			mMeltingMaxTemperatureCurves = new Dictionary<IPcrExperimentProject, XYSeries[,]>();
		}

		protected void InitializeDisplayedResultColumns(PcrSystemType systemType)
		{
			mDisplayedResultColumns = new List<string>[mConfigurationService.ChannelCount];
			for (int i = 0; i < mDisplayedResultColumns.Length; i++)
			{
				mDisplayedResultColumns[i] = new List<string>();
			}
		}

		protected virtual List<IPcrExperimentProject> CheckExperimentImportStandardCurve()
		{
			string key = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[0];
			int minStandardCellCount = mConfigurationService.AnalysisConfiguration.MinStandardCellCount;
			List<IPcrExperimentProject> list = new List<IPcrExperimentProject>();
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				if (mProject == null)
				{
					continue;
				}
				bool flag = false;
				IProjectItem[] projectItems = mProject.ProjectItems;
				foreach (IProjectItem projectItem in projectItems)
				{
					if (projectItem != null && !string.IsNullOrEmpty(projectItem.Name) && projectItem.ChannelConfiguration.IsSelected && projectItem.ChannelConfiguration.IsAvailable)
					{
						int position = projectItem.ChannelConfiguration.Position;
						for (int j = 0; j < mProject.TubeCount; j++)
						{
							IAbsoluteAnalysisParameterConfiguration absoluteAnalysisParameterConfiguration = projectItem.TubeAnalysisParameterConfiguration[j] as IAbsoluteAnalysisParameterConfiguration;
							if (absoluteAnalysisParameterConfiguration != null && !projectItem.TubeAnalysisParameterConfiguration[j].ProjectName.Equals("N/A"))
							{
								int actualAmplificationDetectionCycle = GetActualAmplificationDetectionCycle();
								if (absoluteAnalysisParameterConfiguration.AbsoluteAnalysisType.Equals(AbsoluteAnalysisType.ExternalStandardCurve))
								{
									flag = true;
									break;
								}
								if (absoluteAnalysisParameterConfiguration.AbsoluteAnalysisType.Equals(AbsoluteAnalysisType.Quantitative) && mProject.PcrProgram.AmplificationDetectionCount >= mConfigurationService.AnalysisConfiguration.MinCycleCount && actualAmplificationDetectionCycle >= mConfigurationService.AnalysisConfiguration.MinCycleCount && mCellTypeLists[mProject][position, j][key].Count < minStandardCellCount)
								{
									flag = true;
									break;
								}
							}
						}
					}
					if (flag)
					{
						break;
					}
				}
				if (flag)
				{
					list.Add(mProject);
				}
			}
			return list;
		}

		protected virtual bool GetProjectMeltingStatus(IPcrExperimentProject project, out IMeltingSegment meltingSegment)
		{
			meltingSegment = project.PcrProgram.GetMeltingSegment(0);
			if (meltingSegment != null)
			{
				return meltingSegment.IsAvailable;
			}
			return false;
		}

		protected virtual void InitializeProjectItemOption(ref IAbsoluteAnalysisParameterConfiguration analysisOption, ref IMeltingAnalysisParameterConfiguration meltingOption, IProjectItem projectItem, IPcrExperimentProject project, int tubeIndex)
		{
			if (projectItem.TubeAnalysisParameterConfiguration[tubeIndex].ProjectName.Equals("N/A"))
			{
				analysisOption = null;
				meltingOption = null;
				return;
			}
			analysisOption = projectItem.TubeAnalysisParameterConfiguration[tubeIndex] as IAbsoluteAnalysisParameterConfiguration;
			analysisOption.Project = project;
			(analysisOption as AnalysisParameterConfiguration).IsNeedReAnalysis = true;
			(analysisOption as AnalysisParameterConfiguration).ProjectChannel = projectItem.ChannelConfiguration.Position;
			if (mCurrentImportStandardCurve != null && mCurrentImportStandardCurve.ContainsKey(project.Name))
			{
				if (analysisOption.AbsoluteAnalysisType == AbsoluteAnalysisType.Quantitative)
				{
					analysisOption.ImportedStandardCurve = mCurrentImportStandardCurve[project.Name];
				}
				else
				{
					analysisOption.ImportedStandardCurve = null;
				}
			}
			else
			{
				analysisOption.ImportedStandardCurve = null;
			}
			if (projectItem.TubeMeltingAnalysisParameterConfiguration != null && projectItem.TubeMeltingAnalysisParameterConfiguration.Count > 0)
			{
				meltingOption = projectItem.TubeMeltingAnalysisParameterConfiguration[tubeIndex] as IMeltingAnalysisParameterConfiguration;
			}
		}

		protected virtual void CalculateSpecialData(string analyzeMethod, IPcrExperimentProject project, int projectIndex)
		{
			if (project.IsUseAdvancedRule && analyzeMethod == "Analyze")
			{
				mRuleEditorService.AnalysisRule(project);
			}
		}

		protected virtual AnalysisError ExecuteAnalyze(AnalyzeDelegate analyzeDelegate)
		{
			AnalysisError result = AnalysisError.NA;
			List<IProjectItem>[] array = new List<IProjectItem>[mProjects.Count];
			string text = string.Empty;
			List<IProjectItem>[] array2 = new List<IProjectItem>[mProjects.Count];
			string text2 = string.Empty;
			int num = 0;
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				array[num] = new List<IProjectItem>();
				array2[num] = new List<IProjectItem>();
				if (mProject.PcrProgram.ALLDetectionCount <= 0)
				{
					MessageBox.Show(mResourceManager.GetString("NoCycleInProgram") + mResourceManager.GetString("FailToAnalysisData"), mResourceManager.GetString("ErrorString"));
					return AnalysisError.LessCycle;
				}
				if (mProject.Cells == null)
				{
					MessageBox.Show(mResourceManager.GetString("NoCellInExperiment") + mResourceManager.GetString("FailToAnalysisData"), mResourceManager.GetString("ErrorString"));
					return AnalysisError.LessCycle;
				}
				IMeltingSegment meltingSegment;
				bool projectMeltingStatus = GetProjectMeltingStatus(mProject, out meltingSegment);
				IProjectItem[] projectItems = mProject.ProjectItems;
				foreach (IProjectItem projectItem in projectItems)
				{
					if (projectItem != null && !string.IsNullOrEmpty(projectItem.Name) && projectItem.ChannelConfiguration.IsSelected && projectItem.ChannelConfiguration.IsAvailable)
					{
						int position = projectItem.ChannelConfiguration.Position;
						IAbsoluteAnalysisParameterConfiguration analysisOption = null;
						IMeltingAnalysisParameterConfiguration meltingOption = null;
						for (int j = 0; j < mProject.TubeCount; j++)
						{
							InitializeProjectItemOption(ref analysisOption, ref meltingOption, projectItem, mProject, j);
							if (analysisOption != null)
							{
								switch (analyzeDelegate(mCellTypeLists[mProject][position, j], this, analysisOption, meltingOption, projectMeltingStatus))
								{
								case AnalysisError.LessStandard:
								{
									array[num].Add(projectItem);
									string text4 = text;
									text = text4 + mResourceManager.GetString("TargetString") + projectItem.Name + " " + mResourceManager.GetString("LessStdWell") + mConfigurationService.AnalysisConfiguration.MinStandardCellCount + mResourceManager.GetString("ToAnalysisData") + "\r\n";
									result = AnalysisError.LessStandard;
									break;
								}
								case AnalysisError.LessCycle:
								{
									array2[num].Add(projectItem);
									string text3 = text2;
									text2 = text3 + mResourceManager.GetString("TargetString") + projectItem.Name + " " + mResourceManager.GetString("LessCycle") + mConfigurationService.AnalysisConfiguration.MinCycleCount + mResourceManager.GetString("ToAnalysisData") + "\r\n";
									result = AnalysisError.LessCycle;
									break;
								}
								default:
									array[num].Add(null);
									break;
								}
								RefreshThresholdCurveLine(analysisOption.ManualThreshold, mProject, position, j, true, false);
								if (meltingSegment != null && meltingOption != null && meltingSegment.IsAvailable && mProject.SystemType == PcrSystemType.AbsoluteAnalysis)
								{
									RefreshMeltingThresholdCurveLine(meltingOption.NoiseThreshold, mProject, position, j, true, false);
									RefreshMeltingMinTemperatureCurveLine(meltingOption.MinTemperature, mProject, position, j, true, false);
									RefreshMeltingMaxTemperatureCurveLine(meltingOption.MaxTemperature, mProject, position, j, true, false);
								}
							}
						}
					}
					Application.DoEvents();
				}
				num++;
				CalculateSpecialData(analyzeDelegate.Method.Name, mProject, num - 1);
			}
			if (!mPcrStructure.PcrDataFile.IsLoadingAfterExperiment)
			{
				if (!string.IsNullOrEmpty(text))
				{
					MessageBox.Show(text, mResourceManager.GetString("ErrorString"));
				}
				if (!string.IsNullOrEmpty(text2))
				{
					MessageBox.Show(text2, mResourceManager.GetString("ErrorString"));
				}
			}
			mAllProjectsReAnalysis = false;
			return result;
		}

		protected virtual bool CheckColumnInExperiment(IColumn column)
		{
			if (column == null)
			{
				return false;
			}
			if (column.Classification != ColumnClassification.RelativeQuantificationResult && column.Classification != ColumnClassification.GeneTypeResult && column.Classification != ColumnClassification.GeneScanResult && column.Classification != ColumnClassification.AlleleResult)
			{
				return column.Classification != ColumnClassification.AlleleInformation;
			}
			return false;
		}

		private bool GetCellRowColumnIndex(IPcrCell pcrCell, out int row, out int column)
		{
			row = 0;
			column = 0;
			try
			{
				string cellPosition = pcrCell.CellPosition;
				string text = cellPosition.Substring(0, 1);
				string value = cellPosition.Substring(1, cellPosition.Length - text.Length);
				column = Convert.ToInt32(value);
				if (column < 1 || column > mConfigurationService.ModuleCol * mConfigurationService.ModuleCount)
				{
					return false;
				}
				row = Convert.ToChar(text) - 65 + 1;
				return row >= 1 && row <= mConfigurationService.ModuleRow;
			}
			catch
			{
				return false;
			}
		}

		private bool CheckSubModuleIsInCurrentExperiment(ISubModule subModule)
		{
			if (subModule.IsAvailable() && mPcrStructure.PcrDataFile.IsNewPcrFile)
			{
				return true;
			}
			if (subModule.PcrExperiment == null)
			{
				return false;
			}
			return subModule.PcrExperiment.Equals(this);
		}

		private bool IsAllBlankCells(int channelIndex)
		{
			if ((mCellTypeLists == null || mCellTypeLists.Keys.Count == 0) && !RefreshCellTypeList())
			{
				throw new Exception(mResourceManager.GetString("ErrorRefreshingCells"));
			}
			string[] detectionTypeArray = mConfigurationService.GetDetectionTypeArray(mSystemType);
			foreach (IPcrExperimentProject mProject in mProjects)
			{
				if (!mCellTypeLists.ContainsKey(mProject))
				{
					continue;
				}
				for (int i = 0; i < mProject.TubeCount; i++)
				{
					for (int j = 0; j < detectionTypeArray.Length - 1; j++)
					{
						if (mCellTypeLists[mProject][channelIndex, i] != null && mCellTypeLists[mProject][channelIndex, i].ContainsKey(detectionTypeArray[j]) && mCellTypeLists[mProject][channelIndex, i][detectionTypeArray[j]].Count > 0)
						{
							return false;
						}
					}
				}
			}
			return true;
		}

		private bool CheckAllChannelBlank()
		{
			bool result = true;
			for (int i = 0; i < mIsChannelUsed.Length; i++)
			{
				if (mIsChannelUsed[i] && !IsAllBlankCells(i))
				{
					result = false;
					break;
				}
			}
			return result;
		}

		private XYSeries CreateThresholdLine(double thresholdValue, string projectName)
		{
			XYSeries xYSeries = new XYSeries();
			xYSeries.Points.Add(new XYDataPoint(mAmplificationStartCycle, thresholdValue, projectName, false));
			xYSeries.Points.Add(new XYDataPoint(mAmplificationStopCycle, thresholdValue, projectName, false));
			xYSeries.Visible = false;
			xYSeries.Label = projectName;
			PaintElement value = new PaintElement(mConfigurationService.AmplificationLightCurveConfiguration.ThresholdCurveColor);
			xYSeries.PEs.Clear();
			xYSeries.PEs.Add(value);
			return xYSeries;
		}

		private XYSeries CreateMeltingThresholdLine(double thresholdValue, string projectName, IMeltingSegment meltingSegment)
		{
			XYSeries xYSeries = new XYSeries();
			xYSeries.Points.Add(new XYDataPoint(meltingSegment.StartDegree, thresholdValue, projectName, false));
			xYSeries.Points.Add(new XYDataPoint(meltingSegment.StopDegree, thresholdValue, projectName, false));
			xYSeries.Visible = false;
			xYSeries.Label = projectName;
			PaintElement value = new PaintElement(mConfigurationService.AmplificationLightCurveConfiguration.ThresholdCurveColor);
			xYSeries.PEs.Clear();
			xYSeries.PEs.Add(value);
			return xYSeries;
		}

		private XYSeries CreateMeltingTemperatureLine(double value, string projectName, Color color)
		{
			XYSeries xYSeries = new XYSeries();
			xYSeries.Points.Add(new XYDataPoint(value, -1.0, projectName, false));
			xYSeries.Points.Add(new XYDataPoint(value, 1.0, projectName, false));
			xYSeries.Visible = false;
			xYSeries.Label = projectName;
			PaintElement value2 = new PaintElement(color);
			xYSeries.PEs.Clear();
			xYSeries.PEs.Add(value2);
			return xYSeries;
		}

		public int GetActualAmplificationDetectionCycle()
		{
			if (mRunningStatus.IsRestart && mProjects != null && mProjects.Count > 0)
			{
				return mProjects[0].MinRealTimeAmplificationCycle;
			}
			if (mAmplificationStopCycle > 0)
			{
				if (mRunningStatus.DetectCycle <= mAmplificationStopCycle)
				{
					return mRunningStatus.DetectCycle;
				}
				return mAmplificationStopCycle;
			}
			return mAmplificationStopCycle;
		}

		public int GetActualMeltingDetectionCycle()
		{
			if (mRunningStatus.IsRestart && mProjects != null && mProjects.Count > 0)
			{
				return mProjects[0].MinRealTimeMeltingCycle;
			}
			if (mAmplificationStopCycle > 0)
			{
				if (mRunningStatus.DetectCycle <= mAmplificationStopCycle)
				{
					return 0;
				}
				return mRunningStatus.DetectCycle - mAmplificationStopCycle;
			}
			return mRunningStatus.DetectCycle;
		}
	}
}
